//
//  OosObjectFactory.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 3/22/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import "OosObjectCreator.h"


@implementation OosObjectCreator

+ (id) createObjectFromClass: (Class) aClass
{
	NSEntityDescription *description;
	description = [self descriptionForClass: aClass];
	return [self createObjectFromDescription: description];
}

+ (id) createObjectFromDescription: (NSEntityDescription *) description
{
	Oos4ios *oos4ios = [Oos4ios instance];
	NSManagedObjectContext *context = [oos4ios managedContext];
	return [[[NSManagedObject alloc] initWithEntity:description 
					 insertIntoManagedObjectContext:context] autorelease];
}

+ (NSEntityDescription *) descriptionForClass:(Class)aClass
{
	Oos4ios *oos4ios = [Oos4ios instance];
	NSManagedObjectContext *context = [oos4ios managedContext];
	NSString *className = NSStringFromClass(aClass);
	return [NSEntityDescription entityForName: className 
							  inManagedObjectContext:context];
}

@end
